import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { getModulesAll } from '/@/api/system/system';

export const columns: BasicColumn[] = [
  {
    title: '标题',
    dataIndex: 'title',
    width: 120,
    ellipsis: true,
    resizable: true,
    slots: { customRender: 'title' },
  },
  {
    title: '发件人',
    dataIndex: 'senderRealName',
    width: 100,
    ellipsis: true,
    resizable: true,
    // slots: { customRender: 'senderRealName' },
  },
  {
    title: '等级',
    dataIndex: 'msgLevel',
    width: 100,
    ellipsis: true,
    resizable: true,
    customRender: ({ text }) => {
      return text === 0 ? '普通' : text === 1 ? '紧急' : '';
    },
  },
  {
    title: '日期',
    dataIndex: 'sendTime',
    width: 150,
    ellipsis: true,
    resizable: true,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'kind',
    label: '',
    component: 'Input',
    colProps: { span: 8 },
    slot: 'kind',
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'byModuleCode',
    label: '基准模块',
    required: true,
    component: 'ApiSelect',
    colProps: { span: 22 },
    componentProps: {
      api: getModulesAll,
      labelField: 'name',
      valueField: 'code',
      showSearch: true,
      optionFilterProp: 'label',
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'f',
    label: ' ',
    component: 'Input',
    colProps: { span: 22 },
    render: () => {
      return '注意：同步后权限将与所选择的基准模块一致)';
    },
  },
];

export const byOptions = [
  {
    label: '标题',
    value: 'title',
  },
  {
    label: '内容',
    value: 'content',
  },
  {
    label: '发件人',
    value: 'sender',
  },
  {
    label: '未读消息',
    value: 'notreaded',
  },
];
